package multiThreading;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.LinkedTransferQueue;
import java.util.concurrent.TransferQueue;

public class J{
    private static LinkedList q=new LinkedList();
    public static void main(String arg[]){
        new j1("A",q).start();
        new j1("B",q).start();
    }

}
class j1 extends Thread{
    private LinkedList q;
    public j1(String name,LinkedList q){
        super(name);
        this.q=q;
    }
    public void print(){
        String value;
        Iterator it=q.iterator();
        while (it.hasNext()){
            System.out.print((String)it.next());
        }
        System.out.println();
    }

    @Override
    public void run() {
        for(int i=0;i<7;i++){
            q.add(Thread.currentThread().getName()+i);
            print();
        }

    }
}
